define([ "app", "jquery", "md5", "ecb", "artDialog","iframeTools","services/UserService",
		"resources/UserResource", "resources/LabelResource" ],
		function(app) {

			var deps = [ "$scope", "$state", "$window", "$modalInstance", "$location", "$stateParams", "UserService", "UserResource", "LabelResource" ];

			function controller($scope, $state, $window, $modalInstance, $location, $stateParams, UserService, UserResource, LabelResource) {
				
				
				$scope.saveLabel = function() {
					if ($scope.labelCreateForm.$invalid) {
						return false;
					}
					$scope.labelCreateForm.$invalid = true;
					
					LabelResource.save($scope.labelVo).success(function(data){
						$scope.labelCreateForm.$invalid = false;
						if (data.labelId && data.resCode=='0000') {
							$modalInstance.close($scope.labelVo);
						}
						else{
							art.dialog.alert(data.msg);
							$modalInstance.close($scope.labelVo);
						}
		            });
					
				};

				$scope.close = function($scope,LabelResource) {
					$modalInstance.close();
				};
			}
			controller.$inject = deps;
			return app.lazy.controller("AddLabelController", controller);
		});
